class Search < ActiveRecord::Base
  has_many :search_queries
  has_many :guests, :through => :search_queries
  has_many :users, :through => :search_queries
  
  def to_url
    keywords.downcase.gsub(/[^a-z0-9 ]/, '_').gsub(/[ ]/, '-')
  end
  
  def to_param
    (id = self.id) ? id.to_s + "-#{self.to_url}" : nil
  end
end
